Imports DotNetNuke
Imports System.Web.UI
Imports System.Collections.Generic
Imports System.Reflection
Imports DotNetNuke.Services.Localization
Imports DotNetNuke.Services.Exceptions
Imports System.Web.UI.WebControls
Imports DotNetNuke.Common
Imports DotNetNuke.Common.Utilities
Imports DotNetNuke.Entities.Modules
Imports DotNetNuke.Entities.Modules.Actions
Imports DotNetNuke.Security
Imports DotNetNuke.Security.Roles


Namespace SGW.ComunicadorWeb

    ''' -----------------------------------------------------------------------------
    ''' <summary>
    ''' The ViewDynamicModule class displays the content
    ''' </summary>
    ''' <remarks>
    ''' </remarks>
    ''' <history>
    ''' </history>
    ''' -----------------------------------------------------------------------------
    Public MustInherit Class ViewComunicadorWeb
        Inherits Entities.Modules.PortalModuleBase
        Implements Entities.Modules.IActionable
        Dim PageIndex As Integer

#Region " Private Members "

        Private _controlToLoad As String

#End Region

#Region " Private Methods "

        Private Sub ReadQueryString()

            If Not (Request("sgwcomunicador") Is Nothing) Then

                ' Load the appropriate Control
                '
                Select Case Request("sgwcomunicador").ToLower()

                    Case "prioridades"
                        _controlToLoad = "ViewSGW_Prioridades.ascx"

                    Case "categorias"

                        _controlToLoad = "ViewSGW_Categorias.ascx"

                    Case "editcategoria"
                        _controlToLoad = "EditCategoria.ascx"

                    Case "agregarpeticion"
                        _controlToLoad = "AgregarPeticion.ascx"
                    Case "listamensajes"
                        _controlToLoad = "inicio.ascx"

                    Case "editmensaje"
                        _controlToLoad = "editmensaje.ascx"

                    Case "editconfiguracion"
                        _controlToLoad = "editconfiguracion.ascx"

                    Case "editlayoutfiles"
                        If (Me.UserInfo.IsSuperUser) Then
                            _controlToLoad = "EditLayoutFiles.ascx"
                        Else
                            _controlToLoad = "LandingPage.ascx"
                        End If

                    Case "editlayoutsettings"
                        If (Me.UserInfo.IsSuperUser) Then
                            _controlToLoad = "EditLayoutSettings.ascx"
                        Else
                            _controlToLoad = "LandingPage.ascx"
                        End If

                    Case "editpermissions"
                        If (Me.IsEditable) Then
                            _controlToLoad = "EditPermissions.ascx"
                        Else
                            _controlToLoad = "LandingPage.ascx"
                        End If

                    Case "editphotos"
                        _controlToLoad = "EditPhotos.ascx"

                    Case "editproperty"
                        _controlToLoad = "EditProperty.ascx"

                    Case "editpropertytype"
                        If (Me.IsEditable) Then
                            _controlToLoad = "EditPropertyType.ascx"
                        Else
                            _controlToLoad = "LandingPage.ascx"
                        End If

                    Case "editpropertytypes"
                        If (Me.IsEditable) Then
                            _controlToLoad = "EditPropertyTypes.ascx"
                        Else
                            _controlToLoad = "LandingPage.ascx"
                        End If

                    Case "edittemplatedefinition"
                        If (Me.UserInfo.IsSuperUser) Then
                            _controlToLoad = "EditTemplateDefinition.ascx"
                        Else
                            _controlToLoad = "LandingPage.ascx"
                        End If

                    Case "edittemplatedefinitions"
                        If (Me.UserInfo.IsSuperUser) Then
                            _controlToLoad = "EditTemplateDefinitions.ascx"
                        Else
                            _controlToLoad = "LandingPage.ascx"
                        End If

                    Case "exporttemplatedefinition"
                        If (Me.UserInfo.IsSuperUser) Then
                            _controlToLoad = "ExportTemplateDefinition.ascx"
                        Else
                            _controlToLoad = "LandingPage.ascx"
                        End If

                    Case "importtemplatedefinition"
                        If (Me.UserInfo.IsSuperUser) Then
                            _controlToLoad = "ImportTemplateDefinition.ascx"
                        Else
                            _controlToLoad = "LandingPage.ascx"
                        End If

                    Case "landingpage"
                        _controlToLoad = "LandingPage.ascx"

                    Case "propertymanager"
                        _controlToLoad = "EditProperties.ascx"

                    Case "view"
                        _controlToLoad = "ViewProperty.ascx"

                    Case "viewfeatured"
                        _controlToLoad = "ViewType.ascx"

                    Case "viewsearch"
                        _controlToLoad = "ViewType.ascx"

                    Case "viewtype"
                        _controlToLoad = "ViewType.ascx"

                    Case Else
                        _controlToLoad = "LandingPage.ascx"

                End Select

            Else

                _controlToLoad = "Inicio.ascx"

            End If

            'If (Me.PropertySettings.Template = "") Then
            '    If (Me.IsEditor) Then
            '        If (_controlToLoad <> "EditTemplateDefinitions.ascx" And _controlToLoad <> "ImportTemplateDefinition.ascx") Then
            '            _controlToLoad = "ChangeTemplate.ascx"
            '        End If
            '    Else
            '        _controlToLoad = "NoTemplate.ascx"
            '    End If
            'End If

        End Sub

        Private Sub LoadControlType()

            Dim objPortalModuleBase As PortalModuleBase = CType(Me.LoadControl(_controlToLoad), PortalModuleBase)

            If Not (objPortalModuleBase Is Nothing) Then

                objPortalModuleBase.ModuleConfiguration = Me.ModuleConfiguration
                objPortalModuleBase.ID = System.IO.Path.GetFileNameWithoutExtension(_controlToLoad)
                phControls.Controls.Add(objPortalModuleBase)

            End If

        End Sub

#End Region

#Region "Event Handlers"

        ''' -----------------------------------------------------------------------------
        ''' <summary>
        ''' Page_Load runs when the control is loaded
        ''' </summary>
        ''' <remarks>
        ''' </remarks>
        ''' <history>
        ''' </history>
        ''' -----------------------------------------------------------------------------
        Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load


        End Sub
        Private Sub Page_Initialize(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init

            ReadQueryString()
            LoadControlType()

        End Sub

#End Region

#Region "Optional Interfaces"

        ''' -----------------------------------------------------------------------------
        ''' <summary>
        ''' Registers the module actions required for interfacing with the portal framework
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        ''' <history>
        ''' </history>
        ''' -----------------------------------------------------------------------------
        Public ReadOnly Property ModuleActions() As Entities.Modules.Actions.ModuleActionCollection Implements Entities.Modules.IActionable.ModuleActions
            Get
                Dim Actions As New ModuleActionCollection
                'Actions.Add(GetNextActionID, Localization.GetString(Entities.Modules.Actions.ModuleActionType.AddContent, LocalResourceFile), Entities.Modules.Actions.ModuleActionType.AddContent, "", "", EditUrl(), False, Security.SecurityAccessLevel.Edit, True, False)
                Actions.Add(GetNextActionID, Localization.GetString("txtPrioridades", Me.LocalResourceFile), ModuleActionType.ContentOptions, "", "", NavigateURL(Me.TabId, "", "sgwcomunicador=prioridades"), False, SecurityAccessLevel.Admin, True, False)
                Actions.Add(GetNextActionID, Localization.GetString("txtCategorias", Me.LocalResourceFile), ModuleActionType.ContentOptions, "", "", NavigateURL(Me.TabId, "", "sgwcomunicador=categorias"), False, SecurityAccessLevel.Admin, True, False)
                Actions.Add(GetNextActionID, Localization.GetString("txtConfiguracion", Me.LocalResourceFile), ModuleActionType.ContentOptions, "", "", NavigateURL(Me.TabId, "", "sgwcomunicador=EditConfiguracion"), False, SecurityAccessLevel.Admin, True, False)
                'Actions.Add(GetNextActionID, Localization.GetString("EditLayoutFiles", Me.LocalResourceFile), ModuleActionType.ContentOptions, "", "", NavigateURL(Me.TabId, "", "sgwcomunicador=EditLayoutFiles"), False, SecurityAccessLevel.Host, True, False)
                'Actions.Add(GetNextActionID, Localization.GetString("EditLayoutSettings", Me.LocalResourceFile), ModuleActionType.ContentOptions, "", "", NavigateURL(Me.TabId, "", "sgwcomunicador=EditLayoutSettings"), False, SecurityAccessLevel.Host, True, False)
                'Actions.Add(GetNextActionID, Localization.GetString("EditPermissions", Me.LocalResourceFile), ModuleActionType.ContentOptions, "", "", NavigateURL(Me.TabId, "", "sgwcomunicador=EditPermissions"), False, SecurityAccessLevel.Edit, True, False)
                'Actions.Add(GetNextActionID, Localization.GetString("EditTemplateDefinitions", Me.LocalResourceFile), ModuleActionType.ContentOptions, "", "", NavigateURL(Me.TabId, "", "sgwcomunicador=EditTemplateDefinitions"), False, SecurityAccessLevel.Host, True, False)

                Return Actions
            End Get
        End Property

#End Region

    End Class

End Namespace
